package com.bz.xtcx.manager.service.impl;

import com.bz.xtcx.manager.comom.XtcxException;
import com.bz.xtcx.manager.entity.User;
import com.bz.xtcx.manager.enums.UserTypeEnum;
import com.bz.xtcx.manager.mapper.DataStatisticsMapper;
import com.bz.xtcx.manager.service.IDataService;
import com.bz.xtcx.manager.utils.KeyValueTransTool;
import com.bz.xtcx.manager.utils.WzStrUtil;
import com.bz.xtcx.manager.vo.VoCheck;
import com.bz.xtcx.manager.vo.VoTaskSum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.*;

@Service
public class DataService extends BaseService implements IDataService{

    @Autowired
    private DataStatisticsMapper dataStatisticsMapper;

    @Autowired
    private KeyValueTransTool keyValueTransTool;
    
    /**
     * total 实时总数统计
     * month 按月累计、新增统计
     * @param tableName
     * @return
     */
    private Map<String, Object> getTotalAndMonthData(String tableName){
        Map<String, Object> map = new HashMap<String, Object>();
        if(tableName == null) {
            return null;
        }
        int count = dataStatisticsMapper.count(tableName);
        map.put("total", count);
        String date = this.getMyDate(-6);
        date = date + "-01";
        List<Map<String, Object>>  list = dataStatisticsMapper.groupByMonth(tableName, date);
        List<Map<String, Integer>> mylist = new LinkedList<Map<String, Integer>>();
        List<Map<String, Integer>> myLJlist = new LinkedList<Map<String, Integer>>();
        Map<String, Integer> mymap = null;
        Map<String, Integer> myljmap = null;
        int ljCnt = 0;
        first : for(int i=-6; i<=0; i++) {
            mymap = new HashMap<String, Integer>();
            myljmap = new HashMap<String, Integer>();
            date = this.getMyDate(i);
            //System.out.println(i);
            //System.out.println(date);
            for(Map<String, Object> data : list) {
                if(date.equals(data.get("date"))) {
                    mymap.put(date, Integer.parseInt(data.get("count").toString()));
                    mylist.add(mymap);

                    ljCnt += Integer.parseInt(data.get("count").toString());
                    myljmap.put(date, ljCnt);
                    myLJlist.add(myljmap);
                    continue first;
                }
            }
            mymap.put(date, 0);
            mylist.add(mymap);
            myljmap.put(date, ljCnt);
            myLJlist.add(myljmap);
        }
        
        map.put("month", mylist);
        map.put("monthLJ", myLJlist);
        return map;
    }
    
    @Override
    public Map<String, Object> getUserStatistics() {
        String tableName = "`bus_user`";
        //String group = "user_type";
        Map<String, Object> map = this.getTotalAndMonthData(tableName);
        //List<Map<String, Object>>  list = dataStatisticsMapper.groupByType(tableName, group);
        //map.put(group, list);
        return map;
    }

    public Map<String, Object> getByCountry(String tableName, String country) {
        if(tableName == null) {
            return null;
        }
        Map<String, Object> map = new HashMap<String, Object>();
        List<Map<String, Object>>  list = null;
        if(StringUtils.isEmpty(country)) {//省
            list = dataStatisticsMapper.groupByCountry0(tableName);
        }else if(country.indexOf(",") == -1) {//市
            //country = "\"" + country + "\"";
            list = dataStatisticsMapper.groupByCountry1(tableName, country);
        }else if(country.indexOf(",") > -1){//区
            country = country.split(",")[1];
            list = dataStatisticsMapper.groupByCountry2(tableName, country);
        }
        map.put("country", list);
        return map;
    }
    
    @Override
    public Map<String, Object> getUserCountry(String country) {
        String tableName = "`bus_user`";
        Map<String, Object> map = this.getByCountry(tableName, country);
        return map;
    }
    
    @Override
    public Map<String, Object> getUserType(String type) {
        return null;
    }

    @Override
    public Map<String, Object> getUserStatistics(VoCheck check) {
        String tableName = "`bus_user`";
        StringBuilder queryField = new StringBuilder();
        StringBuilder queryCond = new StringBuilder();
        StringBuilder groupBy = new StringBuilder();
        Map<String, Object> map = new HashMap<String, Object>();;
//        if(check.isIfSite()) {
//            int count = check.getSites().size();
//            groupBy.append("JSON_EXTRACT(NULLIF(country,''),'$[").append(count).append("]'),");
//            queryField.append("JSON_EXTRACT(NULLIF(country,''),'$[").append(count).append("]') country,");
//            if(count != 0) {
//                queryCond.append(" and JSON_EXTRACT(NULLIF(country,''),'$[").append(count-1).append("]') = '").append(check.getSites().get(count-1)).append("'");
//            }
//        }
        if(check.isIfType()) {
            groupBy.append("user_type,");
            queryField.append("user_type userType,");
        }
        
        if(check.getTypes()!= null && check.getTypes().size() > 0) {
            queryCond.append(" and user_type in").append(this.getIds(check.getTypes()));
        }
        
        queryField.append(" count(*) count ");
        groupBy.deleteCharAt(groupBy.length() - 1);
        //queryField.deleteCharAt(queryField.length() - 1);
        
        List<Map<String, Object>> list = dataStatisticsMapper.commonGroupBy(tableName.toString(), queryField.toString(), queryCond.toString(), groupBy.toString());
        for (Map<String, Object> vo : list) {
            if (null != vo.get("userType") && 1 == ((Integer) vo.get("userType")).intValue()) {
                vo.put("userType", "个人/专家");
            } else if (null != vo.get("userType") && 2 == ((Integer) vo.get("userType")).intValue()) {
                vo.put("userType", "企业");
            } else if (null != vo.get("userType") && 3 == ((Integer) vo.get("userType")).intValue()) {
                vo.put("userType", "服务机构");
            } else if (null != vo.get("userType") && 4 == ((Integer) vo.get("userType")).intValue()) {
                vo.put("userType", "高校院所");
            }
        }
        map.put("user", list);
        return map;
    }
    
    private String getIds(List<String> ss) {
        StringBuilder sb = new StringBuilder();
        sb.append("(");
        for(String s : ss) {
            sb.append("'").append(s).append("',");
        }
        sb.deleteCharAt(sb.length() - 1);
        sb.append(")");
        return sb.toString();
    }
    
    
    /**
     * 获取当前日期前 n 个月前的第一天
     * @return
     */
    private String getMyDate(int n) {
        String date = null;
        Calendar c = Calendar.getInstance();
        c.add(Calendar.MONTH, n);
        int year = c.get(Calendar.YEAR);
        int month = c.get(Calendar.MONTH) + 1;
        date = year + "-" + month;  
        // date = year + "-" + month + "-01";
        return date;
    }
    
    public static void main(String[] args) {
        String country = "100000";
        System.out.println(country.indexOf(","));
         for(int i=-6; i<=0; i++) {
             System.out.println(i);
         }
        Calendar c = Calendar.getInstance();
        
        System.out.println(c.get(Calendar.YEAR));
        System.out.println(c.get(Calendar.MONTH) + 1);
        System.out.println(c.get(Calendar.DATE));
        c.add(Calendar.MONTH, -6);
        System.out.println(c.get(Calendar.YEAR));
        System.out.println(c.get(Calendar.MONTH) + 1);
        System.out.println(c.get(Calendar.DATE));
    }
    
    private String getLibTableName(int formType) {
        String tableName = null;
        if(UserTypeEnum.Expert.key() == formType) {
            tableName = "`lib_expert`";
        }else if(UserTypeEnum.Enterprise.key() == formType) {
            tableName = "`lib_enterprise`";
        }else if(UserTypeEnum.Service.key() == formType) {
            tableName = "`lib_service`";
        }else if(UserTypeEnum.College.key() == formType) {
            tableName = "`lib_college`";
        }else if(UserTypeEnum.Results.key() == formType) {
            tableName = "`lib_results`";
        }else if(UserTypeEnum.Requirement.key() == formType) {
            tableName = "`lib_requirements`";
        }else {
            return null;
        }
        return tableName;
    }
    
    private Map<String, String> getLibGroupBy(int formType, VoCheck check) {
        String tableName = null;
        StringBuilder queryField = new StringBuilder();
        StringBuilder queryCond = new StringBuilder();
        StringBuilder groupBy = new StringBuilder();
        Map<String, String> map = new HashMap<String, String>();
        List<String> country = check.getSites();
        int count = Integer.parseInt(check.getSite());
        if(check.isIfSite()) {
//            count = country.size();
            groupBy.append("TRIM(BOTH '\"' FROM IFNULL(JSON_EXTRACT(NULLIF(t.country,''),'$[").append(count - 1).append("]'),'')),");
            queryField.append("TRIM(BOTH '\"' FROM IFNULL(JSON_EXTRACT(NULLIF(t.country,''),'$[").append(count -1).append("]'),'')) country,");
            if(null != country || 0 < country.size()) {
                for (int x = 0; x < country.size(); x++) {
                    queryCond.append(" and t.country like '%").append(country.get(x)).append("%' ");
                }
            }
        }
        
        if(UserTypeEnum.Expert.key() == formType) {
            tableName = "`lib_expert` t";
            
            if(check.isIfDomain()) {
                tableName = "(select c.*,researchField from lib_expert c,(select a.id, REPLACE(REPLACE(REPLACE(substring_index(substring_index(a.research_field,',',b.help_topic_id+1),',',-1),'\"',''),'[',''),']','') researchField from lib_expert a"
                        + " join mysql.help_topic b on b.help_topic_id < (length(a.research_field) - length(replace(a.research_field,',',''))+1) ) d where c.id=d.id) t";
                groupBy.append("t.researchField,");
                queryField.append("researchField,");
            }
            if(check.getDomains() != null && check.getDomains().size() > 0) {
                queryCond.append(" and t.researchField in").append(this.getIds(check.getDomains()));
            }
            if(check.isIfSex()) {
                groupBy.append("t.sex,");
                queryField.append("t.sex,");
            }
            if(check.getSexs() != null && check.getSexs().size() > 0) {
                queryCond.append(" and t.sex in").append(this.getIds(check.getSexs()));
            }
            if(check.isIfEducation()) {
                groupBy.append("t.education,");
                queryField.append("t.education,");
            }
            if(check.getEducations() != null && check.getEducations().size() > 0) {
                queryCond.append(" and t.education in").append(this.getIds(check.getEducations()));
            }
            if(check.isIfDegree()) {
                groupBy.append("t.degree,");
                queryField.append("t.degree,");
            }
            if(check.getDegrees() != null && check.getDegrees().size() > 0) {
                queryCond.append(" and t.degree in").append(this.getIds(check.getDegrees()));
            }
            
        }else if(UserTypeEnum.Enterprise.key() == formType) {
            //tableName = "`lib_enterprise` t";
            tableName = "(select c.id, c.is_listed, c.country, d.registered_type, e.registered_capital, f.domain from `lib_enterprise` c,"
                    + "(select a.id, REPLACE(REPLACE(REPLACE(substring_index(substring_index(a.registered_type,',',b.help_topic_id+1),',',-1),'\"',''),'[',''),']','') registered_type "
                    + "from `lib_enterprise` a join mysql.help_topic b on b.help_topic_id < (length(a.registered_type) - length(replace(a.registered_type,',',''))+1) )d,"
                    + "(select a.id, REPLACE(REPLACE(REPLACE(substring_index(substring_index(a.registered_capital,',',b.help_topic_id+1),',',-1),'\"',''),'[',''),']','') registered_capital "
                    + "from `lib_enterprise` a join mysql.help_topic b on b.help_topic_id < (length(a.registered_capital) - length(replace(a.registered_capital,',',''))+1) )e,"
                    + "(select a.id, REPLACE(REPLACE(REPLACE(substring_index(substring_index(a.domain,',',b.help_topic_id+1),',',-1),'\"',''),'[',''),']','') domain "
                    + "from `lib_enterprise` a join mysql.help_topic b on b.help_topic_id < (length(a.domain) - length(replace(a.domain,',',''))+1) )f"
                    + " where c.id=d.id and c.id=e.id and c.id=f.id ) t";
            if(check.isIfDomain()) {
                groupBy.append("t.domain,");
                queryField.append("t.domain domain,");
            }
            if(check.getDomains() != null && check.getDomains().size() > 0) {
                queryCond.append(" and t.domain in").append(this.getIds(check.getDomains()));
            }
            if(check.isIfScale()) {
                groupBy.append("t.registered_capital,");
                queryField.append("t.registered_capital scale,");
            }
            if(check.getScales() != null && check.getScales().size() > 0) {
                queryCond.append(" and t.registered_capital in").append(this.getIds(check.getScales()));
            }
            if(check.isIfRegType()) {
                groupBy.append("t.registered_type,");
                queryField.append("t.registered_type regType,");
            }
            if(check.getRegTypes() != null && check.getRegTypes().size() > 0) {
                queryCond.append(" and t.registered_type in").append(this.getIds(check.getRegTypes()));
            }
            if(check.isIfIsListed()) {
                groupBy.append("t.is_listed,");
                queryField.append("t.is_listed isListed,");
            }
            if(check.getIsListeds() != null && check.getIsListeds().size() > 0) {
                queryCond.append(" and t.is_listed in").append(this.getIds(check.getIsListeds()));
            }
        }else if(UserTypeEnum.Service.key() == formType) {
            tableName = "`lib_service` t";
            tableName = "(select c.id, c.country, d.orgNature, e.orgType from `lib_service` c,"
                    + "(select a.id, REPLACE(REPLACE(REPLACE(substring_index(substring_index(a.org_nature,',',b.help_topic_id+1),',',-1),'\"',''),'[',''),']','') orgNature "
                    + "from `lib_service` a join mysql.help_topic b on b.help_topic_id < (length(a.org_nature) - length(replace(a.org_nature,',',''))+1) )d,"
                    + "(select a.id, REPLACE(REPLACE(REPLACE(substring_index(substring_index(ifnull(a.org_type,''),',',b.help_topic_id+1),',',-1),'\"',''),'[',''),']','') orgType "
                    + "from `lib_service` a join mysql.help_topic b on b.help_topic_id < (length(ifnull(a.org_type,'')) - length(replace(ifnull(a.org_type,''),',',''))+1) )e"
                    + " where c.id=d.id and c.id=e.id ) t";
            if(check.isIfNature()) {
                groupBy.append("t.orgNature,");
                queryField.append("t.orgNature nature,");
            }
            if(check.getNatures() != null && check.getNatures().size() > 0) {
                queryCond.append(" and t.orgNature in").append(this.getIds(check.getNatures()));
            }
            if(check.isIfCategory()) {
                groupBy.append("t.orgType,");
                queryField.append("t.orgType category,");
            }
            if(check.getCategorys() != null && check.getCategorys().size() > 0) {
                queryCond.append(" and t.orgType in").append(this.getIds(check.getCategorys()));
            }
        }else if(UserTypeEnum.College.key() == formType) {
            tableName = "`lib_college` t";
        }else if(UserTypeEnum.Results.key() == formType) {
            tableName = "`lib_results` t";
            tableName = "(select c.*, d.domain2, e.stage2 from `lib_results` c,"
                    + "(select a.id, REPLACE(REPLACE(REPLACE(substring_index(substring_index(a.domain,',',b.help_topic_id+1),',',-1),'\"',''),'[',''),']','') domain2 from `lib_results` a"
                    + " join mysql.help_topic b on b.help_topic_id < (length(a.domain) - length(replace(a.domain,',',''))+1) ) d, "
                    + "(select a.id, REPLACE(REPLACE(REPLACE(substring_index(substring_index(a.stage,',',b.help_topic_id+1),',',-1),'\"',''),'[',''),']','') stage2 from `lib_results` a"
                    + " join mysql.help_topic b on b.help_topic_id < (length(a.stage) - length(replace(a.stage,',',''))+1) ) e "
                    + "where c.id=d.id and c.id=e.id ) t";
            if(check.isIfDomain()) {
                groupBy.append("t.domain2,");
                queryField.append("t.domain2 domain,");
            }
            if(check.getDomains() != null && check.getDomains().size() > 0) {
                queryCond.append(" and t.domain2 in").append(this.getIds(check.getDomains()));
            }
            if(check.isIfStage()) {
                groupBy.append("t.stage2,");
                queryField.append("t.stage2 stage,");
            }
            if(check.getStages() != null && check.getStages().size() > 0) {
                queryCond.append(" and t.stage2 in").append(this.getIds(check.getStages()));
            }
        }else if(UserTypeEnum.Requirement.key() == formType) {
            tableName = "`lib_requirements` t";
            if(check.isIfDomain()) {
                tableName = "(select c.*, d.domain2 from `lib_requirements` c,"
                        + "(select a.id, REPLACE(REPLACE(REPLACE(substring_index(substring_index(a.domain,',',b.help_topic_id+1),',',-1),'\"',''),'[',''),']','') domain2 from `lib_requirements` a"
                        + " join mysql.help_topic b on b.help_topic_id < (length(a.domain) - length(replace(a.domain,',',''))+1) ) d "
                        + "where c.id=d.id) t";
                groupBy.append("t.domain2,");
                queryField.append("t.domain2 domain,");
            }
            if(check.getDomains() != null && check.getDomains().size() > 0) {
                queryCond.append(" and t.domain2 in").append(this.getIds(check.getDomains()));
            }
        }else {
            return null;
        }
        if(groupBy.length() == 0) {
            return null;
        }
        queryField.append(" count(distinct id) count");
        groupBy.deleteCharAt(groupBy.length() - 1);

        map.put("tableName", tableName.toString());
        map.put("queryField", queryField.toString());
        map.put("queryCond", queryCond.toString());
        map.put("groupBy", groupBy.toString());
        return map;
    }

    @Override
    public Map<String, Object> getLib(int formType) {
        String tableName = this.getLibTableName(formType);
        Map<String, Object> map = this.getTotalAndMonthData(tableName);
        return map;
    }

    @Override
    public Map<String, Object> getLibStatistics(int formType, VoCheck check) throws XtcxException {
        Map<String, String> mapLib = getLibGroupBy(formType, check);
        Map<String, Object> map = null;
        if(mapLib != null && mapLib.size() > 0) {
            map = new HashMap<String, Object>();
            List<Map<String, Object>> list = dataStatisticsMapper.commonGroupBy(mapLib.get("tableName"), mapLib.get("queryField"), mapLib.get("queryCond"), mapLib.get("groupBy"));
            for (Map<String, Object> vo : list) {
                vo.put("country", WzStrUtil.defaultIfBlank(keyValueTransTool.getPcaaValByKey((String) vo.get("country")), (check.isIfSite() ? "未知地域" : "")));
                if (1 == formType) {
                    vo.put("education", WzStrUtil.defaultIfBlank(keyValueTransTool.getZJValByKey("学历", (String) vo.get("education")), (check.isIfEducation() ? "未知学历" : "")));
                    vo.put("degree", WzStrUtil.defaultIfBlank(keyValueTransTool.getZJValByKey("学位", (String) vo.get("degree")), (check.isIfDegree() ? "未知学位" : "")));
                    vo.put("sex", WzStrUtil.defaultIfBlank(keyValueTransTool.getZJValByKey("性别", (String) vo.get("sex")), (check.isIfSex() ? "未知性别" : "")));
                    vo.put("researchField", WzStrUtil.defaultIfBlank(keyValueTransTool.getZJValByKey("研究领域", (String) vo.get("researchField")), (check.isIfDomain() ? "未知研究领域" : "")));
                } else if (2 == formType) {
                    vo.put("isListed", WzStrUtil.defaultIfBlank(keyValueTransTool.getQYValByKey("是否上市", (String) vo.get("isListed")), (check.isIfIsListed() ? "未知上市情况" : "")));
                    vo.put("scale", WzStrUtil.defaultIfBlank(keyValueTransTool.getQYValByKey("企业规模", (String) vo.get("scale")), (check.isIfScale() ? "未知企业规模" : "")));
                    vo.put("regType", WzStrUtil.defaultIfBlank(keyValueTransTool.getQYValByKey("注册类型", (String) vo.get("regType")), (check.isIfRegType() ? "未知注册类型" : "")));
                    vo.put("domain", WzStrUtil.defaultIfBlank(keyValueTransTool.getQYValByKey("所属领域", (String) vo.get("domain")), (check.isIfDomain() ? "未知所属领域" : "")));
                } else if (3 == formType) {
                    vo.put("nature", WzStrUtil.defaultIfBlank(keyValueTransTool.getFWJGValByKey("机构性质", (String) vo.get("nature")), (check.isIfNature() ? "未知机构性质" : "")));
                    vo.put("category", WzStrUtil.defaultIfBlank(keyValueTransTool.getFWJGValByKey("机构类别", (String) vo.get("category")), (check.isIfCategory() ? "未知机构类别" : "")));
                } else if (6 == formType) {
                    vo.put("stage", WzStrUtil.defaultIfBlank(keyValueTransTool.getCGValByKey("所处阶段", (String) vo.get("stage")), (check.isIfStage() ? "未知所处阶段" : "")));
                    vo.put("domain", WzStrUtil.defaultIfBlank(keyValueTransTool.getCGValByKey("所属领域", (String) vo.get("domain")), (check.isIfDomain() ? "未知所属领域" : "")));
                } else if (7 == formType) {
                    vo.put("domain", WzStrUtil.defaultIfBlank(keyValueTransTool.getXQValByKey("所属领域", (String) vo.get("domain")), (check.isIfDomain() ? "未知所属领域" : "")));
                }
            }
            map.put("lib", list);
        }
        return map;
    }

    @Override
    public Map<String, Object> getTaskDoing() {
        Map<String, Object> map = new HashMap<String, Object>();
        User user = this.getUser();
        if(user != null) {
            map.put("11", dataStatisticsMapper.findMeetingFromer(user.getUserId()));
            map.put("12", dataStatisticsMapper.findMeetingTargeter(user.getUserId()));
        }
        return map;
    }

    @Override
    public Map<String, Object> getDjStatistics() {
        Integer amCnt = dataStatisticsMapper.countAllMeeting();
        Integer asmCnt = dataStatisticsMapper.countAllSuccessMeeting();
        List<VoTaskSum> amtLs = dataStatisticsMapper.countAllMeetingByType();
        for (VoTaskSum amt : amtLs) {
            if (0 == amt.getFormType()) {
                amt.setFormTypeStr("专家对接");
            } else if (1 == amt.getFormType()) {
                amt.setFormTypeStr("需求对接");
            } else if (2 == amt.getFormType()) {
                amt.setFormTypeStr("成果对接");
            } else if (3 == amt.getFormType()) {
                amt.setFormTypeStr("服务对接");
            } else {
                amt.setFormTypeStr("");
            }
        }
        List<VoTaskSum> asmtLs = dataStatisticsMapper.countAllSuccessMeetingByType();
        for (VoTaskSum asmt : asmtLs) {
            if (0 == asmt.getFormType()) {
                asmt.setFormTypeStr("专家对接");
            } else if (1 == asmt.getFormType()) {
                asmt.setFormTypeStr("需求对接");
            } else if (2 == asmt.getFormType()) {
                asmt.setFormTypeStr("成果对接");
            } else if (3 == asmt.getFormType()) {
                asmt.setFormTypeStr("服务对接");
            } else {
                asmt.setFormTypeStr("");
            }
        }
        Map<String, Object> retMap = new HashMap<String, Object>();
        retMap.put("allMeeting", amCnt);
        retMap.put("allSuccessMeeting", asmCnt);
        retMap.put("allMeetingByType", amtLs);
        retMap.put("allSuccessMeetingByType", asmtLs);
        return retMap;
    }

    // add by wangtao on 20190103 for 对接可以按时间过滤后再进行统计 start
    @Override
    public Map<String, Object> getDjStatisticsByTime(String stTime, String edTime) {
        Integer amCnt = dataStatisticsMapper.countAllMeetingByDatetime(stTime, edTime);
        Integer asmCnt = dataStatisticsMapper.countAllSuccessMeetingByDatetime(stTime, edTime);
        List<VoTaskSum> amtLs = dataStatisticsMapper.countAllMeetingByTypeAndDatetime(stTime, edTime);
        for (VoTaskSum amt : amtLs) {
            if (0 == amt.getFormType()) {
                amt.setFormTypeStr("专家对接");
            } else if (1 == amt.getFormType()) {
                amt.setFormTypeStr("需求对接");
            } else if (2 == amt.getFormType()) {
                amt.setFormTypeStr("成果对接");
            } else if (3 == amt.getFormType()) {
                amt.setFormTypeStr("服务对接");
            } else {
                amt.setFormTypeStr("");
            }
        }
        List<VoTaskSum> asmtLs = dataStatisticsMapper.countAllSuccessMeetingByTypeAndDatetime(stTime, edTime);
        for (VoTaskSum asmt : asmtLs) {
            if (0 == asmt.getFormType()) {
                asmt.setFormTypeStr("专家对接");
            } else if (1 == asmt.getFormType()) {
                asmt.setFormTypeStr("需求对接");
            } else if (2 == asmt.getFormType()) {
                asmt.setFormTypeStr("成果对接");
            } else if (3 == asmt.getFormType()) {
                asmt.setFormTypeStr("服务对接");
            } else {
                asmt.setFormTypeStr("");
            }
        }
        Map<String, Object> retMap = new HashMap<String, Object>();
        retMap.put("allMeeting", amCnt);
        retMap.put("allSuccessMeeting", asmCnt);
        retMap.put("allMeetingByType", amtLs);
        retMap.put("allSuccessMeetingByType", asmtLs);
        return retMap;
    }
    // add by wangtao on 20190103 for 对接可以按时间过滤后再进行统计 end

    @Override
    public Map<String, Object> getVisiterStatistics() {
        Map<String, Object> retMap = new HashMap<String, Object>();
        int cnt = dataStatisticsMapper.countAllVisiter();
        retMap.put("allVisiter", cnt);
        // add by wangtao on 2190103 for 增加按月统计访问量 start
        List<Map<String, Integer>> cntByMonth = dataStatisticsMapper.countVisiterByMonth();
        retMap.put("visiterByMonth", cntByMonth);
        // add by wangtao on 2190103 for 增加按月统计访问量 end
        return retMap;
    }

}
